'''
Created on 2010-11-25

@author: kenny
'''
# -*- coding: utf-8; tab-width: 4; indent-tabs-mode: t -*-
from yapsy.IPlugin import IPlugin
class Char2Ascii(IPlugin):
    '''
    This class is used to convert characters to ascii (Chinese, GBK in most case)
    '''
    def __init__(self):
        print "Char2Ascii init"
    
    def activate(self):
        print "Char2Ascii activated"    
    
    def run(self,arg):
        str = arg.decode("utf8")
        flag=0
        for c in str.encode("gb2312"):
            if flag % 2 == 0:
                print "======"
            print "%X" % ord(c)
            flag +=1
        print "======"